package io.jnet.server.accepthandler.impl;

import java.nio.channels.AsynchronousServerSocketChannel;
import java.nio.channels.AsynchronousSocketChannel;
import java.util.concurrent.ExecutorService;
import io.jnet.common.api.AioListener;
import io.jnet.common.api.ChannelContext;
import io.jnet.common.build.ChannelContextBuilder;
import io.jnet.common.build.ChannelContextConfig;
import io.jnet.common.channelcontext.ChannelAttachChannelContext;

public class ChannelAttachAcceptHandler extends AbstractAcceptHandler
{
    
    public ChannelAttachAcceptHandler(ExecutorService businessExecutorService, AsynchronousServerSocketChannel serverSocketChannel, ChannelContextBuilder channelContextBuilder, AioListener serverListener)
    {
        super(businessExecutorService, serverSocketChannel, channelContextBuilder, serverListener);
    }
    
    @Override
    protected ChannelContext parse(ExecutorService businessExecutorService, AsynchronousSocketChannel socketChannel, ChannelContextConfig config, AioListener listener)
    {
        ChannelContext serverChannelContext = new ChannelAttachChannelContext(//
                businessExecutorService, //
                config.getBufStorage(), //
                config.getMaxMerge(), //
                listener, //
                config.getInProcessors(), //
                config.getOutProcessors(), //
                socketChannel, //
                config.getFrameDecodec());
        return serverChannelContext;
    }
}
